package com.ghn.cocknovel.ui.activity.setting

import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import androidx.annotation.RequiresApi
import com.example.basemodel.base.BaseHeadVMActivity
import com.example.basemodel.base.DefaultHeadStyle
import com.ghn.cocknovel.R
import com.ghn.cocknovel.databinding.ActivityChangePassWordBinding
import com.ghn.cocknovel.ui.activity.setting.vm.ChangePassWordViewModel

/**
 *@author: Administrator
 *2023/10/10
 *desc:修改密码
 */
class ChangePassWordActivity : BaseHeadVMActivity<ChangePassWordViewModel, ActivityChangePassWordBinding, DefaultHeadStyle>() {
    override fun layoutId(): Int = R.layout.activity_change_pass_word

    @RequiresApi(Build.VERSION_CODES.M)
    override fun initView(savedInstanceState: Bundle?) {
        mHeadStyle.setLeftImageResource(R.mipmap.ic_back_black)
        mHeadStyle.setTitleBackgroundColor(getColor(R.color.colorBackGround))
        mHeadStyle.setTitleColor("修改密码", getColor(R.color.black))
        mDatabind.btnSubmit.setOnClickListener {
            if (!TextUtils.isEmpty(mDatabind.changgepassworded.text.toString())) {
                mViewModel.getchangepassword(mDatabind.changgepassworded.text.toString())
            }
        }
    }

    override fun createObserver() {
        mViewModel.changepassword.observe(this) {
            showMsg("修改成功")
            finish()
        }
    }

}